
class Test:
    """this is a test"""

    def __init__(self):
        """init of Test"""
        pass

    def __call__(self, *args, **kwargs):
        print("-----call------")

    def __str__(self):
        return "something"

    def __getitem__(self, item):
        print(item)

    def __setitem__(self, key, value):
        print(key + value)

    def __delitem__(self, key):
        print(key)

def main():
    print(Test.__doc__) # 类说明
    test = Test()
    print(test.__module__) # 所在模块
    print(test.__class__) # 对象所属类
    test() # 调用__call__
    print(test) # 类描述 __str__

    res = test['key1'] # 自动触发执行 __getitem__
    test['key2'] = 'hhh' # 自动触发执行 __setitem__
    del test['key1'] # 自动触发执行 __delitem__

if __name__ == '__main__':
    main()